<template>
  <div class="app-container">
    <!-- 添加或修改定位器对话框 -->
    <com-dialog :cstyle="'height:150px'" :title="title" :visible="open" :width="'360px'" :footer="false"
                @update:visible="(v) => { this.open = v }">
      <div slot="content">
        <el-form ref="form" :model="form" :rules="rules" label-width="100px">
          <el-form-item prop="time">

            <template slot="label">
              延迟时间
<!--              <i class="el-icon-question"></i>-->
            </template>
            <el-input-number :controls="false" :min="0" v-model="form.time" placeholder="请输入延迟时间"/>
          </el-form-item>
          <el-form-item label="执行次数" prop="number">
            <el-input-number v-model="form.number" :min="0" :controls="false" placeholder="请输入执行次数"/>

          </el-form-item>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button type="primary" @click="cancel">取 消</el-button>
      </div>
    </com-dialog>
  </div>
</template>

<script>
import ComDialog from "@/components/ComDialog";
import {TextSubmit} from '../../../../wailsjs/go/main/App'

export default {
  components: {ComDialog},
  name: "GpsLocatorInfoOpt",
  data() {
    return {
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 表单参数
      form: {
        num: 1,
        time: 1
      },
      // 表单校验
      rules: {
        Time: [
          {required: true, message: "延迟时间不能为空", trigger: "blur"}
        ],
        Number: [
          {required: true, message: "执行次数不能为空", trigger: "blur"}
        ],

      }
    };
  },
  created() {

  },
  methods: {
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        num: 1,
        time: 1,
        name:null,
      };
      this.$forceUpdate();
    },
    /** 新增按钮操作 */
    handleText(row) {
      this.reset();
      this.title = "测试运行";
      this.open = true;
this.form.name=row.Name
      this.$forceUpdate();


    },

    /** 提交按钮 */
    submitForm() {
      let _this = this;
      this.$refs["form"].validate(valid => {
        if (valid) {
          TextSubmit(_this.form.name,_this.form.time,_this.form.number).then(res => {
              if (res == '1') {
                this.open = false;
              }
            })

        }
      });
    }
  }
};
</script>
<style lang="less"></style>